package com.nxy.cpfsfe.busi.bolag;
/**
 * @author  wp
 * @date  2019年8月29日
 */

import com.adtec.starring.datapool.CompSDO;
import com.adtec.starring.datapool.EPOper;
import com.adtec.starring.exception.BaseException;
import com.adtec.starring.struct.dta.DtaInfo;
import com.adtec.starring.util.SpringUtil;
import com.alibaba.fastjson.JSONObject;
import com.nxy.cpfsfe.enumtype.*;
import com.nxy.cpfsfe.mybatis.mapper.TbAMapper;
import com.nxy.cpfsfe.mybatis.mapper.ToOrgMapper;
import com.nxy.cpfsfe.mybatis.mapper.ToParmMapper;
import com.nxy.cpfsfe.mybatis.mapper.TsPCmdMapper;
import com.nxy.cpfsfe.mybatis.pojo.TbA;
import com.nxy.cpfsfe.mybatis.pojo.ToOrg;
import com.nxy.cpfsfe.mybatis.pojo.ToParm;
import com.nxy.cpfsfe.mybatis.pojo.TsPCmd;
import com.nxy.cpfsfe.service.CpfsService;
import com.nxy.cpfsfe.util.*;
import com.nxy.cpfsfe.util.ResponseUtil;
import com.nxy.cpfsfe.util.RpcCommUtil;
import com.nxy.cpfsfe.util.XmlUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * Description: 处理NCS汇兑来账 NPS：120.001.01
 * @author wp
 * @date 2019年8月29日
 */
public class NCSRmVstrASrvBean implements CpfsService {
	
	private final static Logger LOGGER = LoggerFactory.getLogger(NCSRmVstrASrvBean.class);
	SqlSession sqlSession = (SqlSession) SpringUtil.getBean("mybatisSqlSession");		
	

	
	/**
	 * 异步处理,NCS汇兑来账
	 * Description:先登记账务流水，然后判断原支付流水是否存在，最后判断是否为新E支付 
	 * 
	 * @author  wp
	 * @date 2019年8月29日
	 */
	
	public void doService() {
		
		String bizMsg=null;
		try {
			String tpId = DtaInfo.getInstance().getTpId();		
			// 获取输入
			CompSDO inputSdo = (CompSDO) EPOper.getCompSDO(tpId, "ReqBody"); // 获取输入接口		
			bizMsg = (String) inputSdo.getValue("BizMsg")!=null?(String) inputSdo.getValue("BizMsg"):"";
			//String sndAppCd = (String) EPOper.get(tpId, "ReqBean[0].head[0].sndAppCd");
			LOGGER.info("接收到输入BizMsg报文数据：" + bizMsg);
			//登记账务流水
			regAgSeqProc(bizMsg);
		} catch (Throwable e) {
			LOGGER.error("NCS汇兑来账服务处理失败,原报文信息是："+bizMsg,e);
			throw new BaseException(RespCd.NCPO6047,e,"NCS来账");
		}		
	}
	
    // 登记账务流水
	public void regAgSeqProc(String bizMsg) {		
		//解包生成业务map
		Map<String, Object> map=null;
		try {
			map = xml2BizMap(bizMsg);
		}catch (Exception e){
			LOGGER.error("BizMsg报文解包失败",e);
			throw new BaseException(RespCd.NCPO0101, e, "报文解析错误");
		}
		//插入数据账务流水表TbA
		TbAMapper tbAMapper = sqlSession.getMapper(TbAMapper.class);
		int tbAMappertResult = 0;
		String pcId = (String)map.get("pCId");
		String xDirn = (String)map.get("xDirn");
		String chlSeqNo = (String)map.get("/transaction/body/FIToFICstmrCdtTrf/GrpHdr/MsgId");
		String sndOrgId = (String)map.get("/transaction/header/msg/sndMbrCd");
		TbA tbA = new TbA();
		tbA.setChlSeqNo(chlSeqNo);
		tbA.setSndOrgId(sndOrgId);
		tbA.setpCId(pcId);
		tbA.setxDirn(xDirn);
		TbA tbAObj = tbAMapper.query(tbA);
		if(tbAObj == null){
			try{
				map.put("sndSysId",SysEcodeEnum.NCS.getCode());  //设置报文发送方为NCS
				map.put("rcvSysId",SysEcodeEnum.CPFS.getCode()); //设置接收方为CPFS
				String shardingId = (String) map.get("/transaction/header/msg/rcvMbrCd");
				map.put("shardingId", shardingId);
				map.put("acqOrgId", shardingId);
				String reserved1 = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/RmtInf/Remark");
				map.put("reserved1", reserved1);
				String reserved2 = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/RmtInf/OrigMsgId");
				map.put("reserved2", reserved2);
				tbAMappertResult = tbAMapper.insertCdtByMap(map);
				LOGGER.info("账务流水表TbA插入数据：[{}]条,报文标识号MsgId={}",tbAMappertResult,map.get("/transaction/body/FIToFICstmrCdtTrf/GrpHdr/MsgId"));
			}catch (Throwable e) {
				LOGGER.error("插入数据失败：账务流水表TbA:"+map.get("/transaction/body/FIToFICstmrCdtTrf/GrpHdr/MsgId"),e);
			}
		}
		//不管账务流水登记是否成功都要判断支付流水是否存在
		judgePaySeqNo(map,bizMsg);
	}

	//判断支付流水是否存在
	public void judgePaySeqNo(Map<String, Object> map,String bizMsg) {
		String sndMbrCd = (String) map.get("/transaction/header/msg/sndMbrCd");
		ToOrgMapper toOrgMap = sqlSession.getMapper(ToOrgMapper.class);
		ToOrg toOrgObj = new ToOrg();
		toOrgObj.setOrgBNo(sndMbrCd);
		ToOrg toOrg1 = toOrgMap.queryByBNo(toOrgObj);
		String orgCls="";
		if(toOrg1==null){
			orgCls = MbrOTypEnum.issuBNo.getCode();
		}else {
			orgCls = toOrg1.getOrgCls();
		}
		TsPCmdMapper tsPCmdMapper = sqlSession.getMapper(TsPCmdMapper.class);
		TsPCmd tsPCmd = new TsPCmd();
		if(MbrOTypEnum.oldBNo.getCode().equals(orgCls) || MbrOTypEnum.newBNo.getCode().equals(orgCls) ){         //收单行通过MsgId找原交易，分片标识为发送方，收单行发收单行的交易NCS来账发送行和接收行不变。
			String msgId = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/GrpHdr/MsgId");
			LOGGER.info("收单行渠道流水号msgId=[{}]", msgId);
			tsPCmd.setXSeqNo(msgId);
			tsPCmd.setAcqOrgId(sndMbrCd);
			TsPCmd tsPCmd2 = tsPCmdMapper.query(tsPCmd);
			LOGGER.debug("取出的支付流水数据:[{}]",tsPCmd2);
			if(tsPCmd2 != null){
				//修改账务流水表中的接收方系统编号和前置流水号
				ToParm toParm = queryBnoCls((String)map.get("/transaction/header/msg/rcvMbrCd"));
				String bizSysId = SysEcodeEnum.CPFS.getCode();
				if(toParm!=null){
					String remark = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/RmtInf/Remark");
					if(Constant.ZJGJ_FLG.equals(remark) && SysEcodeEnum.CPFS.getCode().equals(tsPCmd2.getBizSysId())){  //找出资金归集的情况
						bizSysId = SysEcodeEnum.CPFS.getCode();
						LOGGER.info("收单行发起的资金归集，接收行所属业务系统编号:[{}]",bizSysId);
						//LOGGER.error("由系统发起的资金归集，但在to_parm表中找到该接收成员行rcvMbrCd所属的业务系统编号:[{}]",toParm.getDataCd());
						//remark不是资金归集的也是业务系统发的
					}else{
						bizSysId = toParm.getDataCd();
					}
				}
				LOGGER.debug("接收行所属业务系统编号:[{}]",bizSysId);
				String tsPSmdCpfsSeqNo = tsPCmd2.getCpfsSeqNo();
                map.put("tsPSmdCpfsSeqNo",tsPSmdCpfsSeqNo);
				updateTbARcvSysId(bizSysId, map);
				//判断系统类型，并转发不同报文
				//String bizSysId = tsPCmd2.getBizSysId();
				judgePaySeqNoTyp(bizSysId,bizMsg,map,tsPCmd2);
			}else{
				LOGGER.warn("原支付交易不存在");
				//给NCS发送NPS.990
				returnNPS990(map);
			}
		}else {
			//发卡行通过remark找原交易
			String remark = "";
			String prtry = (String)map.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/PmtTpInf/CtgyPurp/Prtry");
			if(TsPCmdEnum.Prtry_Reexchange.getCode().equals(prtry)){
				remark = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/RmtInf/OrigMsgId");
				LOGGER.info("发卡行退汇业务渠道流水号OrigMsgId=[{}]", remark);
			}else{
				remark = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/RmtInf/Remark");
				if(StringUtils.isBlank(remark)){
					remark = "remark为空";
				}
				LOGGER.info("发卡行渠道流水号Remark=[{}]", remark);
			}
			tsPCmd.setXSeqNo(remark);
			String acqOrgId = (String) map.get("/transaction/header/msg/rcvMbrCd");
			tsPCmd.setAcqOrgId(acqOrgId);
			TsPCmd tsPCmd2 = tsPCmdMapper.query(tsPCmd);
			LOGGER.debug("取出的支付流水数据:[{}]",tsPCmd2);
			if(tsPCmd2 != null){
				//修改业务状态
				amtCompare(map,tsPCmd2,tsPCmdMapper,remark);
				String bizSysId = tsPCmd2.getBizSysId();
				//修改账务流水表中的接收方系统编号
				String tsPSmdCpfsSeqNo = tsPCmd2.getCpfsSeqNo();
				map.put("tsPSmdCpfsSeqNo",tsPSmdCpfsSeqNo);
				updateTbARcvSysId(bizSysId, map);
				//判断是否为新E支付，并转发网关
				judgePaySeqNoTyp(bizSysId,bizMsg,map,tsPCmd2);
			}else{
				LOGGER.warn("原支付交易不存在");
				//给NCS发送NPS.990
				returnNPS990(map);
			}
		}

	}

    /**
     * 修改账务流水表中的接收方系统编号
     * @param bizSysId
     * @param map
     */
	public void updateTbARcvSysId(String bizSysId,Map<String, Object> map){
		String cpfsSeqNo =  (String)map.get("cpfsSeqNo");
		String acqOrgId = (String) map.get("/transaction/header/msg/rcvMbrCd");
		try{
			TbAMapper tbAMapper = sqlSession.getMapper(TbAMapper.class);
			Map<String,Object> tbAMap = new HashMap<String,Object>();
			tbAMap.put("tsPSmdCpfsSeqNo",map.get("tsPSmdCpfsSeqNo"));
			tbAMap.put("cpfsSeqNo",cpfsSeqNo);
			tbAMap.put("acqOrgId", acqOrgId);
			tbAMap.put("rcvSysId",bizSysId);
			tbAMap.put("updTm",new Timestamp(new Date().getTime()));
			tbAMapper.updateByMap(tbAMap);
			LOGGER.info("更新账务流水表中的接收方系统编号成功......流水号：{}",cpfsSeqNo);
		}catch(Throwable e){
			LOGGER.error("更新数据失败",e);
			throw new BaseException(RespCd.NCPS5006,e);
		}

	}
		//修改状态
		public void amtCompare(Map<String, Object> map,TsPCmd tsPCmd2,TsPCmdMapper tsPCmdMapper,String remark){
			/*String pyrBNo = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/InstgAgt/FinInstnId/ClrSysMmbId/MmbId");
			String pyeBNo = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/InstdAgt/FinInstnId/ClrSysMmbId/MmbId");*/
			String xAmt = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/IntrBkSttlmAmt");
			String respMsgId = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/GrpHdr/MsgId");
			String acqOrgId = (String) map.get("/transaction/header/msg/rcvMbrCd");  //分片标识
			try{
				//更新支付流水表的业务状态为交易成功
				Map<String,Object> tsPCmdMap = new HashMap<String,Object>();
				String orgnBizSta = tsPCmd2.getBizSta();
				tsPCmdMap.put("orgnBizSta", orgnBizSta);   //原状态作为更新条件
				tsPCmdMap.put("bizSta",StatEnum.BIZSTA_SUC.getCode());
				tsPCmdMap.put("ordAmt", xAmt);
				tsPCmdMap.put("respMsgId", respMsgId);
				tsPCmdMap.put("updTm",new Timestamp(new Date().getTime()));
				tsPCmdMap.put("xSeqNo", remark);
				tsPCmdMap.put("acqOrgId", acqOrgId);
				tsPCmdMapper.updateByMap(tsPCmdMap);
				LOGGER.info("更新支付流水业务状态成功......");
			}catch(Throwable e){
				LOGGER.error("更新数据失败",e);
				throw new BaseException(RespCd.NCPS5006,e);
			}

		}
		
	
	//判断原支付流水的类型
	public void judgePaySeqNoTyp(String bizSysId,String bizMsg,Map bizMap,TsPCmd tsPCmd){
		if(SysEcodeEnum.CPFS.getCode().equals(bizSysId)){
		    LOGGER.debug("rpc调用网关发送NPS990开始......");
		    returnNPS990(bizMap);
		}else if(SysEcodeEnum.EPAY.getCode().equals(bizSysId) || SysEcodeEnum.EMAN.getCode().equals(bizSysId)){
			//转发给网关
		    LOGGER.debug("rpc调用网关NPS120开始......");	      
		    returnNPS120(bizSysId,bizMsg);			
		}else{
			LOGGER.info("给新e支付发送应答......");
			returnNPS990(bizMap);
			bizMap.put("addInfo",tsPCmd.getAddInfo());
			bizMap.put("/root/MsgHeader/MsgTp",tsPCmd.getMsgTp());
			bizMap.put("/root/MsgHeader/CorrId",tsPCmd.getComMsgId());
			bizMap.put("/root/MsgHeader/SndSysId",tsPCmd.getBizSysId());
			bizMap.put("/root/MsgHeader/SndBankId",tsPCmd.getSndBNo());
			bizMap.put("RcvSysId",tsPCmd.getBizSysId());
			bizMap.put("SndBankId",tsPCmd.getRcvBNo());
			bizMap.put("RcvBankId",tsPCmd.getSndBNo());
			bizMap.put("CorrId",tsPCmd.getComMsgId());
			bizMap.put("OriTrxId",tsPCmd.getComMsgId());
			bizMap.put("TrxStsCd",RespCd.NCPI0000);
			bizMap.put("BizStsCd",StatEnum.BIZSTA_SUC.getCode());
			bizMap.put("BizStsDesc","交易成功");
			bizMap.put("InstalAmt","0.00");
			bizMap.put("TrxId",bizMap.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/PmtId/TxId"));
			bizMap.put("TrxAmt",bizMap.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/IntrBkSttlmAmt"));
			bizMap.put("SttlmDt",bizMap.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/RmtInf/SttlmDt"));
			bizMap.put("TrxChnlTp",bizMap.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/RmtInf/TranChnlTyp"));
			bizMap.put("EndToEndId",bizMap.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/PmtId/EndToEndId"));
			bizMap.put("MsgId",bizMap.get("/transaction/body/FIToFICstmrCdtTrf/GrpHdr/MsgId"));
			bizMap.put("TrxCtgy",bizMap.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/PmtTpInf/CtgyPurp/Prtry"));
			bizMap.put("TrxSysId",SysEcodeEnum.NCS.getCode());
			bizMap.put("TxNcsId",bizMap.get("/transaction/body/FIToFICstmrCdtTrf/GrpHdr/MsgId"));

			newEPayMsg(bizMap);

		}
	}
	
	public void returnNPS990(Map bizMap){
		String tpId = DtaInfo.getInstance().getTpId();
			
		//转发给网关
		try{	
			String bizMsg990 = ResponseUtil.build990Xml(bizMap);
		    LOGGER.debug("rpc调用网关发送NPS990开始......");
            //判断如果是老系统，sndAppCd为NPS.120来账报文中接收成员行所属的系统编号
			ToParm toParm = queryBnoCls((String)bizMap.get("/transaction/header/msg/rcvMbrCd"));
			if(toParm!=null){
				EPOper.put(tpId, "ReqBean[0].head[0].sndAppCd", toParm.getDataCd());
			}
		    EPOper.put(tpId, "ReqBean[0].head[0].rcvAppCd", SysEcodeEnum.NCS.getCode());
	    	EPOper.put(tpId, "ReqBean[0].head[0].reqServCd", MsgCdOrTpEnum.MSGCD_990.getCode());
		    EPOper.getCompSDO(tpId, "ReqBody").setValue("BizMsg", bizMsg990);
			RpcCommUtil.getInstance().rpcFeToGW(tpId, RpcOutputInfoEnum.OutputName_Pub_Cpfsgw.getCode(),RpcOutputInfoEnum.OutPutSvr_CpfsFwdThrdPrtS.getCode());	
		}catch(Throwable e){
	    	LOGGER.error("调用网关转发NPS.990报文服务失败",e);
			throw new BaseException(RespCd.NCPO6047,e,"调用网关服务异常");			
		}
	}

	public ToParm queryBnoCls(String bno) {
		SqlSession sqlSession = (SqlSession) SpringUtil.getBean("mybatisSqlSession");
		ToParmMapper toParmMapper = sqlSession.getMapper(ToParmMapper.class);
		ToParm toParm = new ToParm();
		toParm.setDataVal(bno);
		toParm.setDataTyp(DataTypeEnum.BIZSYS.getCode());
		List<ToParm> list = toParmMapper.query(toParm);
		if(list != null){
			if(list.size()==1){
				return list.get(0);
			}else if(list.size()==0){
				return null;
			}else{
				throw new BaseException(RespCd.NCPO0007,String.format("参数信息表数据异常，类型:[%s],行号:[%s]",DataTypeEnum.BIZSYS.getCode(),bno));
			}
		}
		return null;
	}
	//返回120并转发给网关
	public void returnNPS120(String bizSysId,String bizMsg){
		String tpId = DtaInfo.getInstance().getTpId();
		try{
			EPOper.put(tpId, "ReqBean[0].head[0].rcvAppCd", bizSysId);
	    	EPOper.put(tpId, "ReqBean[0].head[0].reqServCd", MsgCdOrTpEnum.MSGCD_120.getCode());
		    EPOper.getCompSDO(tpId, "ReqBody").setValue("BizMsg", bizMsg);
			RpcCommUtil.getInstance().rpcFeToGW(tpId, RpcOutputInfoEnum.OutputName_Pub_Cpfsgw.getCode(),RpcOutputInfoEnum.OutPutSvr_CpfsFwdThrdPrtS.getCode());	
		}catch(Throwable e){
	    	LOGGER.error("调用网关转发NPS.120报文服务失败",e);
			throw new BaseException(RespCd.NCPO6047,e,"调用网关服务异常");			
		}
		
	}
	
	

	
	//转换成新E支付返回报文
	public void newEPayMsg(Map bizMap){
		if(!"".equals(StringUtil.trimObject(bizMap.get("addInfo")))){
			String addInfo = (String) bizMap.get("addInfo");
			JSONObject object = JSONObject.parseObject(addInfo);
			if(!"".equals(StringUtil.trimObject(object.getString("NginxUrl")))){
				bizMap.put("NginxUrl",object.getString("NginxUrl"));
				bizMap.put("/root/MsgHeader/ClbckUrl",object.getString("ClbckUrl"));
				returnCPFS(bizMap);
			}

		}

	}

	public void returnCPFS(Map bizMap){
		try{
			String bizMsg501 = ResponseUtil.buildGeneral501Xml(bizMap);
			String bizMsg502 = ResponseUtil.buildGeneral502Xml(bizMap);
			HttpUtil.responseSendJson(bizMsg501,bizMsg502,bizMap);
			LOGGER.debug("返回业务系统报文成功......");
		}catch(Exception e){
			LOGGER.error("返回业务系统报文失败",e);
			throw new BaseException(RespCd.NCPO6047,e,"返回业务系统报文失败");
		}
	}
	
	
    //处理报文
	public Map<String, Object> xml2BizMap (String bizMsg){
	    //拆解xml报文为map1
		Map xml2BizMap =XmlUtil.xml2Map(bizMsg);	
		//把map1<String, String>转换成map<String, Object>
		Map<String, Object> map =xml2BizMap;		
		
		/*特殊处理Ustrd节点,
		 例：把/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/RmtInf/Ustrd[1]=/SttlmDt/2020-01-20
		  处理为/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/RmtInf/SttlmDt=2020-01-20
		*/
		Map<String, Object> mapTemp =new HashMap<String, Object>();
		String ustrdKey = "";
		String ustrdValue = "";
		for(String key:map.keySet()){
			if(key.contains("Ustrd") && map.get(key)!=null ){
				if(map.get(key).toString().contains("/") && map.get(key).toString().split("/").length > 2){
					ustrdKey = key.substring(0, key.lastIndexOf("/")+1) + map.get(key).toString().split("/")[1];
					ustrdValue = map.get(key).toString().split("/")[2];
					mapTemp.put(ustrdKey, ustrdValue);	
				}
			}	
			ustrdKey = "";
			ustrdValue = "";
		}
		map.putAll(mapTemp);
		
		String drcrFlg = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/CdtTrfTxInf/PmtTpInf/CtgyPurp/Prtry");
		drcrFlg = drcrFlg != null ? drcrFlg.toString() : "";
		if(drcrFlg.startsWith("A")||drcrFlg.startsWith("C")){
			drcrFlg="2";
		}else if (drcrFlg.startsWith("B")||drcrFlg.startsWith("D")){
			drcrFlg="1";
		}else {
			drcrFlg="";
		}
		String cpfsSeqNo = (String) map.get("/transaction/body/FIToFICstmrCdtTrf/GrpHdr/MsgId");
		LOGGER.debug("获取前置流水号=[{}]", cpfsSeqNo);
		map.put("cpfsSeqNo", cpfsSeqNo);
		map.put("pNo", "1");
		map.put("drcrFlg", drcrFlg);
		map.put("cpfsD",cpfsSeqNo.substring(0,8));
		map.put("xDirn", TAbEnum.XDirn_Out.getCode());//12前置到通道;21通道到前置
		map.put("bizSta", StatEnum.BIZSTA_SUC.getCode());//来账：00处理成功     
		map.put("pCId",SysEcodeEnum.NCS.getCode());
		map.put("creTm",new Timestamp(new Date().getTime()));
		map.put("Remark","已收到");
		map.put("chkASta",StatEnum.CHKASTA_NOT_START.getCode());//未对账
		LOGGER.info("NCSRmVstrASrvBean插表参数map：" + map.toString());
		return map;	
    }


	public static void main(String[] args) {
		String bizMsg = "<root>\n" +
				"\t<MsgHeader>\n" +
				"\t\t<SndDt></SndDt>\n" +
				"\t\t<MsgTp>CPFS.502.001.01</MsgTp>\n" +
				"\t\t<SndSysId></SndSysId>\n" +
				"\t\t<RcvSysId>NCS</RcvSysId>\n" +
				"\t\t<SndBankId></SndBankId>\n" +
				"\t\t<RcvBankId></RcvBankId>\n" +
				"\t\t<Drctn></Drctn>\n" +
				"\t\t<CorrId></CorrId>\n" +
				"\t\t<TrxId></TrxId>\n" +
				"\t\t<OriTrxId></OriTrxId>\n" +
				"\t\t<SignSN></SignSN>\n" +
				"\t\t<NcrptnSN></NcrptnSN>\n" +
				"\t\t<DgtlEnvlp></DgtlEnvlp>\n" +
				"\t\t<AcctChannel></AcctChannel>\n" +
				"\t\t<ClbckUrl></ClbckUrl>\n" +
				"\t\t<Reserved></Reserved>\n" +
				"\t</MsgHeader>\n" +
				"\t<MsgBody>\n" +
				"\t\t<BizInf>                                            \n" +
				"\t\t\t<TrxStsCd></TrxStsCd>                         \n" +
				"\t\t\t<BizStsCd></BizStsCd>                          \n" +
				"\t\t\t<BizStsDesc></BizStsDesc>                        \n" +
				"\t\t</BizInf>\n" +
				"\t\t<TrxInf>                                             \n" +
				"\t\t\t<TrxCtgy></TrxCtgy>                              \n" +
				"\t\t\t<TrxId></TrxId>                                 \n" +
				"\t\t\t<MsgId></MsgId>                                  \n" +
				"\t\t\t<EndToEndId></EndToEndId>                        \n" +
				"\t\t\t<TxNcsId></TxNcsId>\t\t\t\t\t\t\t\t\n" +
				"\t\t\t<TrxAmt></TrxAmt>\t\t\t\t\t\t\t\t \n" +
				"\t\t\t<SttlmDt></SttlmDt>                             \n" +
				"\t\t\t<TrxSysId></TrxSysId>                            \n" +
				"\t\t\t<TrxChnlTp></TrxChnlTp>\t\t\t\t\t\t\t \n" +
				"\t\t\t<TrxPurpose></TrxPurpose>                        \n" +
				"\t\t\t<TrxRemark></TrxRemark>                  \n" +
				"\t\t</TrxInf>\n" +
				"\t</MsgBody>\n" +
				"</root>";
		Map xml2BizMap =XmlUtil.xml2Map(bizMsg);
		System.out.println(xml2BizMap.toString());
	}
}

